package com.yjz.study.ui.arouter;

import android.os.Bundle;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.alibaba.android.arouter.utils.TextUtils;
import com.yjz.common.base.BaseActivity;
import com.yjz.log.JLog;
import com.yjz.study.R;
import com.yjz.study.arouter.ARouterLogic;
import com.yjz.ui.view.EmptyView;

/**
 * 作用 : 全局统一错误页
 * 作者 : yjz
 * 时间 : 2024/10/24 14:10
 */
@Route(path = ARouterLogic.Path.DEGRADE_GLOBAL_PATH)
public class DegradeGlobalActivity extends BaseActivity {

    @Autowired
    public String title;

    @Autowired
    public String desc;

    @Autowired
    public String action;

    @Override
    public int getLayoutId() {
        return R.layout.activity_global_degrade;
    }

    @Override
    public void init(Bundle savedInstanceState) {
        super.init(savedInstanceState);
        ARouter.getInstance().inject(this);
        findViewById(R.id.action_back).setOnClickListener(view -> {
            finish();
        });
        EmptyView emptyView = findViewById(R.id.empty_view);
        if (!TextUtils.isEmpty(title)) {
            emptyView.setTitle(title);
        }
        if (!TextUtils.isEmpty(desc)) {
            emptyView.setDesc(desc);
        }
        if (!TextUtils.isEmpty(action)) {
            emptyView.setHelpAction(view -> ARouterLogic.INSTANCE.startActivity4Browser(action));
        }
        JLog.aTag("activity", title, desc, action);
    }
}
